<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片弹窗</title>
</head>
<style>
    #myImg {
        border-radius: 5px;
        cursor: pointer;
        transition: 0.3s;
    }
    
    #myImg:hover {
        opacity: 0.7;
    }
    
    .moda {
        display: none;
        position: fixed;
        z-index: 1;
        padding-top: 100px;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background-color: rgb(0, 0, 0);
        background-color: rgba(0, 0, 0, 0.9);
    }
    
    .moda-content {
        margin: auto;
        display: block;
        width: 80%;
        max-width: 700px;
    }
    
    @media only screen and (max-width:700px) {
        .moda-content {
            width: 100%;
        }
    }
    
    .close {
        position: absolute;
        top: 15px;
        right: 35px;
        color: #f1f1f1;
        font-size: 40px;
        font-weight: bold;
        transition: 0.3s;
    }
    
    .close:hover {
        color: #bbb;
        text-decoration: none;
        cursor: pointer;
    }
</style>

<body>
    <img id="myImg" alt="哈哈" width="300px" height="200px" src="https://t7.baidu.com/it/u=2621658848,3952322712&fm=193&f=GIF">

    <div id="myModa" class="moda">
        <span class="close" onclick="document.getElementById('myModa').style.display='none'">&times;</span>
        <img class="moda-content" src="https://t7.baidu.com/it/u=2621658848,3952322712&fm=193&f=GIF">
    </div>
</body>
<script>
    window.onload = function() {
        document.getElementById('myImg').onclick = function() {
            document.getElementById('myModa').style.display = 'block'
        }
    }
</script>


</html>